#include<stdio.h>
void mn(int m,int n,int x[])
{
    int count = n;
    int i = -1;
    int k = 0;
    while (count != 0)
    {
        k++;
        do
        {
            i++;
            i = i % n;
        } while (x[i] == 0);
        
        if(k == m) 
        {
            printf("%d ",x[i]);
            count--;
            x[i] = 0;
            k = 0;
        }
        i = i % n;
    }
}
void byqueue(int m,int n,int x[])
{
    //循环队列
    int front = 0;
    int rear = n-1;
    int count = 0;
    while (front != rear)
    {
        count++;
        if(count != m)
        {
            int a = x[front];
            front = (front + 1) % n;
            rear = (rear + 1) % n;
            x[rear] = a;
        }
        else
        {
            count = 0;
            printf("%d ",x[front]);
            front = (front + 1) % n;
        }
        //printf("\n%d %d\n",front,rear);
    }
    printf("%d",x[front]);
}
int main()
{
    //freopen("in.txt","r",stdin);
    int x[102];
    int m,n;
    scanf("%d %d",&n,&m);
    for(int i = 0; i < n; i++) x[i] = i + 1;
    byqueue(m,n,x);
}